﻿using com.eforceglobal.crux.views.Administration;
using com.eforceglobal.crux.DTOs;
using com.eforceglobal.crux.security;

namespace com.eforceglobal.crux.controllers.Administration
{
    public class ManageCompanyController
    {
        readonly IManageCompany _view;
        public ManageCompanyController(IManageCompany view)
        {
            _view = view;
        }

        public void InitView(bool IsPostBack)
        {
            if (!IsPostBack)
            {
                CheckValidity();

            }
        }

        private void CheckValidity()
        {
            ICruxSecurityManager cruxSecurityManager = CruxSecurityManagerFactory.GetSecurityManager();
            SessionData sessionData = new SessionData();
            UserInformation currentuser = (UserInformation)sessionData.CurrentUser;
            if (!cruxSecurityManager.IsUserSuperAdminOrCompanyAdmin(currentuser, _view.CompanyID))
                NavigationController.OpenErrorPage("803");

        }


        
        public void ManageLocations()
        {
            NavigationController.OpenView("ManageLocations", _view.CompanyID);
        }

        public void ManageDepartments()
        {
            NavigationController.OpenView("ManageDepartments", _view.CompanyID);
        }

        public void ManageUsers()
        {
            NavigationController.OpenView("ManageUsers", _view.CompanyID);
        }

       
    }
}
